const db = require('../config/database');

class TagService {
  async create(name) {
    const sql = `insert into tag set ?`;
    const [result] = await db.query(sql, { name });
    return result;
  }
  async getList({ pageSize, pageNumber }) {
    const offset = (pageNumber - 1) * pageSize;
    const sql = `select * from tag limit ${offset}, ${pageSize};`;
    const [result] = await db.execute(sql, []);
    return result;
  }
  async queryTagByName(name) {
    const sql = `select * from tag where name = ?`;
    const [result] = await db.execute(sql, { name });
    return result;
  }
}

module.exports = new TagService();
